﻿using Catastrophe.BasePC.UI.Ret;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CatastropheDemo.Api
{
    [ApiController]
    [Route("api/[controller]/[action]")]
    public class TestController : Controller
    {
        /// <summary>
        /// http://127.0.0.1:1812/api/Test/Index
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public string Index()
        {
            return "hello api你好";
        }
        [HttpGet]
        public IActionResult GetJson()
        {
            return new JsonResult(new RestResponse
            {
                Message = "测试中文乱码"
            });
        }
        [HttpPost]
        public IActionResult Add(string deviceName, [FromBody] TestEntity entity)
        {
            return Ok(new RestResponse<int>()
            {
                Success = true,
            });
        }
        [HttpPost]
        public IActionResult Update([FromBody] TestEntity entity)
        {
            return Ok(new RestResponse<int>()
            {
                Success = true,
            });
        }
    }
    /// <summary>
    /// 测试实体
    /// </summary>
    public class TestEntity
    {
        public string Name { get; set; }
        public int Age { get; set; }
    }
}
